﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Threading;
using System.Xml;
using System.Web;
using System.Runtime.InteropServices;
using System.IO.Ports;
using CCWin;
namespace weiqijiance
{
    public partial class jiancecanshushezhi : CCSkinMain
    {
        // /声明INI文件的写操作函数 WritePrivateProfileString()
        [DllImport("kernel32")]
        private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);

        //声明INI文件的读操作函数 GetPrivateProfileString()
        [DllImport("kernel32")]
        private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
        private string sPath = null;


        public jiancecanshushezhi()
        {
            InitializeComponent();
            readjcyq();
        }

        //ini文件
        public void Ini(string path)
        {
            this.sPath = path;
        }
        public void Writue(string section, string key, string value)
        {
            // section=配置节，key=键名，value=键值，path=路径
            WritePrivateProfileString(section, key, value, sPath);
        }
        public string ReadValue(string section, string key)
        {
            // 每次从ini中读取多少字节
            System.Text.StringBuilder temp = new System.Text.StringBuilder(255);

            // section=配置节，key=键名，temp=上面，path=路径
            GetPrivateProfileString(section, key, "", temp, 255, sPath);
            return temp.ToString();
        }
        //ini文件
        private void skinButton1_Click(object sender, EventArgs e)
        {
            baocunjcyq();//检定系数设置
        }
        public void readjcyq()
        {
            string path = "";
            path = System.Windows.Forms.Application.StartupPath + path + "\\检测要求设置.ini";
            string path1 = string.Format(@"{0}", path);
            Ini(path1);



            skinCom_ss.Text = ReadValue("设置", "双怠速要求转速");
            skinComboBox1.Text = ReadValue("设置", "油温检测要求");
            skinComboBox2.Text = ReadValue("设置", "ASM要求速度");
            textBox3.Text = ReadValue("设置", "模块输出参数");
            textBox1.Text = ReadValue("设置", "力信号参数");
            skinComboBox3.Text = ReadValue("设置", "ASM结果修正");
            skinComboBox4.Text = ReadValue("设置", "jzjskz");
            skinComboBox5.Text = ReadValue("设置", "ASM流量过低要求");

            comzscs.Text = ReadValue("设置", "双怠速要求转速初始");
            Com_caiyouche.Text = ReadValue("设置", "柴油车CO2");
            cbbobd.Text = ReadValue("设置", "OBD是否开启");



        }
        public void baocunjcyq()//检定系数设置
        {
            string path = "";
            path = System.Windows.Forms.Application.StartupPath  + "\\检测要求设置.ini";
            Ini(path);

            Writue("设置", "双怠速要求转速", skinCom_ss.Text);
            Writue("设置", "油温检测要求", skinComboBox1.Text);
            Writue("设置", "ASM要求速度", skinComboBox2.Text);
            Writue("设置", "模块输出参数", textBox3.Text);
            Writue("设置", "力信号参数", textBox1.Text);
            Writue("设置", "ASM结果修正", skinComboBox3.Text);
            Writue("设置", "jzjskz", skinComboBox4.Text);
            Writue("设置", "ASM流量过低要求", skinComboBox5.Text);

            Writue("设置", "双怠速要求转速初始", comzscs.Text);
            Writue("设置", "柴油车CO2", Com_caiyouche.Text);
            Writue("设置", "OBD是否开启", cbbobd.Text);

            iniclass objini = new iniclass();
            基类窗体.UploadAndDownload fupload = new 基类窗体.UploadAndDownload();
            objini.Ini(System.Windows.Forms.Application.StartupPath + "\\系统信息.ini");
            string sjcxname = objini.ReadValue("系统信息", "检测线名称");
            string sgongweiname = objini.ReadValue("系统信息", "检测工位名称");
            fupload.upload(sjcxname, sgongweiname, "检测要求设置.ini");


        }

        private void jiancecanshushezhi_Load(object sender, EventArgs e)
        {

        }
       


    }
}
